<template>
	<view>
		<web-view :src="src"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src: "",
				job: null,
			}
		},


		watch: {
			src(val) {
				console.log(val)
			}
		},


		onLoad(options) {
			this.src = decodeURIComponent(options.src)

			// #ifdef MP
			if (this.src.indexOf("dingyue1") != -1) {
				this.checkDy();
			}
			// #endif

		},

		onUnload() {
			if (this.job) {
				clearInterval(this.job)
			}
		},


		methods: {
			checkDy() {
				this.job = setInterval(() => {
					const token = uni.storage.get("token")
					uni.request({
						data: {
							uniacid: uni.getStorageSync("uniacid")
						},
						method: 'POST',
						url: 'https://xjz.cyygkj.cn/api/dingyue1', //仅为示例，并非真实接口地址。
						header: {
							'Authorization': `Bearer ${token}` //自定义请求头信息
						},
						success: (res) => {
							if (res.data == 1) {
								uni.showToast({
									title: "订阅成功"
								})

								setTimeout(() => {
									uni.navigateBack()
								}, 1500)
							}
						}
					});
				}, 3000)
			}
		}
	}
</script>

<style>

</style>